package org.bhf.validation.annotations;

/**
 * Copyright (c) 2007, Blue Hole Software. All rights reserved.
 * Code licensed under the Apache 2.0 License:
 * http://www.apache.org/licenses/
 */

import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * All validators must have a <code>Validator</code> annotation and have an inner class of the form
 * <code><pre>
 *
 * </pre></code>
 */
@Documented
@Retention( RetentionPolicy.RUNTIME  )
@Target( ElementType.ANNOTATION_TYPE )
@Inherited
public @interface Validator
{
    /**
     * Utility accessors for <code>Validate</code>
     * @exclude
     */
    public static final class Util
    {
        static final Class<Validator> clazz = Validator.class;

        /**
         * <code>true</code> if the gievn <code>Annotation</code> is a validator.
         * @param annotation <code>Annotation</code> to check.
         * @return <code>true</code> if the gievn <code>Annotation</code> is a validator.
         */
        public static boolean isValidator( final Annotation annotation )
        {
            return annotation.annotationType().getAnnotation( clazz ) != null;
        }
    }
}
